{{--<script src="{{asset('dist/components/order-detail.js')}}?v=201706301106"></script>--}}
<script>
    var evaluate_content = '{{$order->evaluate ? $order->evaluate->oe_response : ''}}';
    var evaluate_time = '{{$order->evaluate ? $order->evaluate->oe_update_time->timestamp : ''}}';

    $(function () {

        var form = new Vue({
            el:'#orderDetail',
            data:{
                doReply:false,
                replyContent:window.evaluate_content,
                replyTime:window.evaluate_time,
                viewOffer:false,
            },
            mounted:function(){
            },
            methods:{
                submit:function(event){
                    if (!validator.form()){
                        return
                    }

                    var self = this;
                    axios.post('/ajax/order/reply', $('#form').serialize())
                        .then(function (response) {
                            if (response.data.code == 200) {
                                alert('回复成功');
                                self.doReply = false;
                                self.replyContent = $('[name=reply]').val();
//                                self.replyTime = moment().format("X");
                                self.replyTime = response.data.timestamp;
                            } else {
                                alert(response.data.message || '回复失败');
                            }
                        },function (response) {
                            alert(response.data.message || '回复失败');
                        }).catch(function (err) {
                        alert('回复失败');
                    });
                },
                previewImage:function(img_url){
                    wx.previewImage({
                        current: img_url, // 当前显示图片的http链接
                        urls: [img_url] // 需要预览的图片http链接列表
                    });
                }
            },
            components:{
            },
            computed:{
            },
        });

        var validator = $("#form").validate({
            rules: {
                order_id:{
                    required:true,
                },
                reply:{
                    required:true,
                },
            },
            messages: {
                reply:{
                    required:'请填写回复内容',
                },
            },
//            submitHandler: function(form) {
//                form.submit();
//            },
        });
    });
</script>

<article class="offer_show mar06" id="orderDetail" v-cloak>

    @if (empty($offering))
        @if ($order->evaluate)
            <div v-show="doReply" class="od_box">
                <div class="od_body ">
                    <form id="form">
                        <input type="hidden" name="order_id" value="{{$order->id}}">
                        <p><textarea name="reply" style="width:85%" rows="5"
                                     placeholder="填写回复"></textarea></p>
                        <div class="overflow_h"><a class="but03" @click="submit">回复</a><a class="but03" @click="
                            doReply = !doReply">取消</a></div>
                    </form>
                </div>
            </div>

            <div class="order_s3 overflow_h">
                <div class="pj_body_01 overflow_h">
                    <span>商家评分：</span>
                    <span class="mar01"><em>时效</em><i>{{$order->evaluate->oe_ontime}}</i><img src="{{asset('images/st01.png')}}"></span>
                    <span class="mar01"><em>态度</em><i>{{$order->evaluate->oe_attitude}}</i><img src="{{asset('images/st01.png')}}"> </span>
                    <span class="mar01"><em>质量</em><i>{{$order->evaluate->oe_quality}}</i><img src="{{asset('images/st01.png')}}"> </span>
                    <span class="mar01"><em>{{$order->evaluate->score_text}}</em><i>{{$order->evaluate->oe_score}}</i><img src="{{$order->evaluate->score_ico}}"> </span>
                </div>
                <div class="pj_body_01">
                    商家评价：{{$order->evaluate->oe_content}}
                </div>
                @if ($order->evaluate->man_made)
                    <div v-if="replyContent == ''" class="pj_body_02">
                        <a class="but05" @click="doReply = !doReply">我要回复</a>
                    </div>
                    <div v-else class="pj_body_02">
                        <p>我的回复：@{{replyContent}}</p>
                        <p><span>@{{replyTime | date}}</span></p>
                    </div>
                @endif
            </div>
        @endif

        <div class="order_s4">
            <p>
                <span><a @click="viewOffer = !viewOffer"><img src="{{asset('images/ico19.png')}}"></a></span>
                @if (!$order->paid  || !$order->myOffer->employed)
                    我的报价金额:<i>{{$order->myOffer->price+$order->replenish_total}}元</i>
                    ({{$order->myOffer->add_time}})
                @else
                    订单金额:<i>{{$order->offer_price+$order->replenish_total}}元</i>
                @endif
            </p>
            @if (!$order->replenishs->isEmpty())
            <p><a style="color:#0068b6" href="{{url("order/replenishlist/{$order->id}")}}">补款明细</a></p>
            @endif
        </div>
    @endif

    <div class="offer_t">
        <div class="help"><a href="https://qy.weixin.qq.com/cgi-bin/wap_getnewsmsg?action=get&__biz=MzA5MjcwNzQ0OQ==&mixuin=MjU1NTUzNjg3ODI1MDQxMzY2Nw==&mid=10001766&idx=1&sn=57b36add84c0fda4a9abb98d8881fabe"><img src="{{asset('images/help.png')}}"></a></div>
        <h2 class="overflow_h"><em>{{$order->service_type_text}}</em>
            @if (!empty($offering))
                <span><a href="{{url("order/offerStart/{$order->id}")}}" class="but">报价雇佣</a></span>
            @endif
        </h2>
        @if (!empty($offering))
        <p>截止报价时间:{{$order->offering_endtime}}</p>
        @endif
        <p>订单服务编号:{{$order->order_number}}</p>
    </div>
    <div class="offer_t2">
        <p>
            @if (empty($offering) && $order->paid)
                <a href="tel:{{$order->detail->merchant_phone ? : ($order->merchant ? $order->merchant->me_phone : '')}}" style="color: #3e3938"><span class="tel_of02"><img
                                src="{{asset('images/ico20.png')}}"></span><span class="tel_of">电话联系下单商家</span></a>
            @endif
            下单商家:
                @if ($order->paid)
                {{$order->detail->merchant_name ? : ($order->merchant ? ($order->merchant->me_truename ? : $order->merchant->me_username) : '')}}
                @else
                    ***
                @endif
        </p>
        <div class="of_p overflow_h">
            @if (!empty($order->detail->merchant_finish_time->timestamp))
            <b><i>商家要求:</i><span class="time">{{$order->detail->merchant_finish_time_text}}
                    前完成服务</span></b>
            @endif
            @if (!$order->paid)
            <b><span class="bao">优先考虑雇佣诚信保证金师傅</span></b>
            @endif
        </div>
        @if (!empty($order->detail->merchant_requirements))
        <p>
            服务要求:{{$order->detail->merchant_requirements}}
        </p>
        @endif
    </div>
    <div class="offer_t3 overflow_h">
        <h2>货品信息</h2>
        <section class="home_poto">
            <ul>
                @foreach ($order->goods as $goods)
                    <li style="margin:0; border-top:0">
                        <img src="{{$goods->goods_img_url}}" @click="previewImage('{{$goods->goods_img_url}}')">
                        <div>
                            <h4>{{$goods->goods_name}}</h4>
                            <p class="col01">数量:{{max($goods->goods_num,1)}}</p>
                            <p>类别:{{$goods->goods_type_text}}</p>
                            <p>备注:{{$goods->goods_mark ? : '- -'}}</p>
                        </div>
                    </li>
                @endforeach

            </ul>
        </section>
    </div>
    <div class="offer_t4 overflow_h">
        <h2 class="of_ico4">客户信息</h2>
        <p>客户名字:{{$order->detail->customer_name ? ($order->paid  && $order->myOffer->employed ? $order->detail->customer_name : '***') : '- -'}}</p>
        <p>客户电话:
            @if ($order->detail->customer_phone)
                @if ($order->paid  && $order->myOffer->employed)
                    <a href="tel:{{$order->detail->customer_phone}}">{{$order->detail->customer_phone}}</a>
                @else
                    ***
                @endif
            @else
                - -
            @endif
        </p>
        <p>客户地址:{{$order->detail->customer_area_text}} {{$order->paid  && $order->myOffer->employed ? $order->detail->customer_address : $order->detail->customer_address_obscure}}</p>
        <p>楼层信息:<i class="col01">{{$order->detail->customer_elevator_text ? : '- -'}}/{{$order->detail->customer_floor ? $order->detail->customer_floor.'楼' : '- -'}}</i></p>
        @if ($order->detail->customer_tmall_number)
            <p>需要天猫喵师傅核销单号:{{$order->detail->customer_tmall_number}}</p>
        @endif
        <p>其它备注:{{$order->detail->customer_memark ? : '- -'}}</p>
    </div>

    <div class="offer_t4 overflow_h">
        <h2 class="of_ico5">物流信息</h2>
        <p>是否到货:{{$order->status->logistics_status_text}}</p>
        <p>物流公司:{{$order->detail->logistics_name ? : '- -'}}</p>
        <p>物流单号:{{$order->detail->logistics_ticketnumber ? ($order->paid  && $order->myOffer->employed ? $order->detail->logistics_ticketnumber : '***') : '- -'}}</p>
        <p>货物件数:<i class="col01">{{$order->detail->logistics_packages ? $order->detail->logistics_packages.'件' : '- -'}}</i></p>
        <p>提货地址:{{$order->detail->logistics_address ? : '- -'}}</p>
        <p>物流电话:
            @if ($order->detail->logistics_phone)
                @if ($order->paid  && $order->myOffer->employed)
                    <a href="tel:{{$order->detail->logistics_phone}}">{{$order->detail->logistics_phone}}</a>
                @else
                    ***
                @endif
            @else
                - -
            @endif
        </p>
        <p>收货人:{{$order->detail->logistics_consignee ? ($order->paid  && $order->myOffer->employed ? $order->detail->logistics_consignee : '***') : '- -'}}</p>
        <p>其它备注:{{$order->detail->logistics_mark ? : '- -'}}</p>
    </div>

    @if (empty($offering))
    <div v-show="viewOffer" class="od_box">
        <form>
            <div class="od_body ">
                <h1>我的报价备注</h1>
                <h2>{{$order->myOffer->message ? : '无备注'}}</h2>
                <div class="overflow_h">
                    <button class="but03" type="button" @click="viewOffer = !viewOffer">确认</button></div>
            </div>
        </form>
    </div>
    @endif

</article>